public class Demo {
}
class Solution {
    /**
     1: 已经种花
     2：不能种花
     3：能种花
     */
    public boolean canPlaceFlowers(int[] flowerbed, int n) {
        for(int i=0; i<flowerbed.length; i++){
            if(flowerbed[i] == 1){
                if(i>0) flowerbed[i-1]=2;
                if(i+1<flowerbed.length) flowerbed[i+1]=2;
            }
        }
        for(int i=0; i<flowerbed.length; i++){
            if(flowerbed[i] == 0){
                n--;
                if(i>0) flowerbed[i-1]=2;
                if(i+1<flowerbed.length) flowerbed[i+1]=2;
            }
        }
        return n <= 0;
    }
}